/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Usuario.java
 *
 * Created on 21/10/2011, 03:07:11 PM
 */
package Vistas;

import Beans.Usuario;
import Controladores.AdmUsuarios;
import Imagenes.CtrlImagen;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.event.*;

/**
 *
 * @author sala3
 */
public class Cuentausuario extends javax.swing.JFrame {

    /** Creates new form Usuario */
    AdmUsuarios Au = new AdmUsuarios();
    Usuario u = new Usuario();
    DefaultTableModel dtm = new DefaultTableModel();
    Vector<Usuario> vc = new Vector<Usuario>();
    String ced="vacio";
    boolean condicion=false;
    int fila;
    public Cuentausuario() {
        initComponents();
        
    }

     public Cuentausuario(AdmUsuarios au) {
        initComponents();
        this.Au=au;
        this.setResizable(false);
        this.DesactivarCampo();
        jComboBox.addItem("Administrador");
        jComboBox.addItem("Consultor");
        jComboBox.addItem("Registrador");
        this.setResizable(false);        
        dtm.addColumn("TIPO");
        dtm.addColumn("USUARIO");
        dtm.addColumn("NOMBRE");

        for(int x =0;x<Au.getUsuarios().size();x++){
            Vector<String> vc = new Vector<String>();
            vc.add(Au.getUsuarios().get(x).getTipo());
            vc.add(Au.getUsuarios().get(x).getNombre_usuario());
            vc.add(Au.getUsuarios().get(x).getNombre());
            dtm.addRow(vc);
        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new CtrlImagen("/Imagenes/a1.jpg");
        jPanelTransparente5 = new Imagenes.JPanelTransparente();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jTxtNombreUsuario = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jComboBox = new javax.swing.JComboBox();
        jButton4 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jTNombre = new javax.swing.JTextField();
        jPasswordField1 = new javax.swing.JPasswordField();
        jPanelTransparente4 = new Imagenes.JPanelTransparente();
        jBBuscar = new javax.swing.JButton();
        jBModificar = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jBRegistrar = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel12.setText("Tipo");

        jLabel13.setText("Usuario");

        jTxtNombreUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTxtNombreUsuarioActionPerformed(evt);
            }
        });

        jLabel1.setText("Contraseña");

        jComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Administrador", "Consultor", "Registrador" }));

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/tango-clear.png"))); // NOI18N
        jButton4.setText("LIMPIAR CAMPOS");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jLabel2.setText("Nombre");

        javax.swing.GroupLayout jPanelTransparente5Layout = new javax.swing.GroupLayout(jPanelTransparente5);
        jPanelTransparente5.setLayout(jPanelTransparente5Layout);
        jPanelTransparente5Layout.setHorizontalGroup(
            jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTransparente5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelTransparente5Layout.createSequentialGroup()
                        .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 316, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jPanelTransparente5Layout.createSequentialGroup()
                        .addGroup(jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING))
                            .addComponent(jLabel12))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPasswordField1, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE)
                            .addComponent(jComboBox, 0, 225, Short.MAX_VALUE)
                            .addComponent(jTNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE)
                            .addComponent(jTxtNombreUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE))
                        .addGap(41, 41, 41))))
        );
        jPanelTransparente5Layout.setVerticalGroup(
            jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelTransparente5Layout.createSequentialGroup()
                .addGap(60, 60, 60)
                .addGroup(jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel13)
                    .addGroup(jPanelTransparente5Layout.createSequentialGroup()
                        .addComponent(jTxtNombreUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(12, 12, 12)
                        .addGroup(jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addGroup(jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(jComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 89, Short.MAX_VALUE)
                .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jBBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/search.png"))); // NOI18N
        jBBuscar.setText("BUSCAR");
        jBBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBBuscarActionPerformed(evt);
            }
        });

        ListSelectionModel lssms =  jTable1.getSelectionModel();
        lssms.addListSelectionListener(new ListSelectionListener(){
            public void valueChanged(ListSelectionEvent e){
                try{
                    if(e.getValueIsAdjusting())return;
                    ListSelectionModel lss=(ListSelectionModel )e.getSource();
                    if(lss.isSelectionEmpty()){
                    }else{
                        condicion=true;
                    }
                }catch(Exception z){
                }
            }
        });
        jBModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/edit.png"))); // NOI18N
        jBModificar.setText("MODIFICAR");
        jBModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBModificarActionPerformed(evt);
            }
        });

        ListSelectionModel lssm =  jTable1.getSelectionModel();
        lssm.addListSelectionListener(new ListSelectionListener(){
            public void valueChanged(ListSelectionEvent e){
                try{
                    if(e.getValueIsAdjusting())return;
                    ListSelectionModel ls=(ListSelectionModel )e.getSource();
                    if(ls.isSelectionEmpty()){
                    }else{
                        condicion=true;
                    }
                }catch(Exception z){
                }
            }
        });
        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/stop.png"))); // NOI18N
        jButton3.setText("ELIMINAR");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jBRegistrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Floppy.png"))); // NOI18N
        jBRegistrar.setText("REGISTRAR");
        jBRegistrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBRegistrarActionPerformed(evt);
            }
        });

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/exit.png"))); // NOI18N
        jButton6.setText("SALIR");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelTransparente4Layout = new javax.swing.GroupLayout(jPanelTransparente4);
        jPanelTransparente4.setLayout(jPanelTransparente4Layout);
        jPanelTransparente4Layout.setHorizontalGroup(
            jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTransparente4Layout.createSequentialGroup()
                .addGroup(jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelTransparente4Layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addGroup(jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jBBuscar, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
                            .addComponent(jBModificar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
                            .addComponent(jButton3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
                            .addComponent(jBRegistrar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelTransparente4Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanelTransparente4Layout.setVerticalGroup(
            jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTransparente4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jBBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jBModificar, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBRegistrar, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(17, Short.MAX_VALUE))
        );

        jTable1.setModel(dtm);
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jTable1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTable1KeyTyped(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanelTransparente5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanelTransparente4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanelTransparente5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanelTransparente4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(20, Short.MAX_VALUE))
        );

        jMenu1.setText("Archivo");

        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/exit.png"))); // NOI18N
        jMenuItem2.setText("Salir");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edicion");

        jMenuItem1.setText("hhgbb}");
        jMenu2.add(jMenuItem1);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTxtNombreUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTxtNombreUsuarioActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jTxtNombreUsuarioActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // LimpiarCampos
        this.LimpiarCampos();
}//GEN-LAST:event_jButton4ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // Salir
        this.dispose();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // Salir
        this.dispose();
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jBBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBBuscarActionPerformed
        // Buscar
      if(jBBuscar.getText().equals("CANCELAR")){
          this.Actualizar();
      }else{
            String c = JOptionPane.showInputDialog("Digite Nombre de la cuenta "
                + "a buscar");
        Usuario u = Au.Consultar(c);
        if(u.getNombre().equals("")){
            JOptionPane.showMessageDialog(null, "Cuenta de usuario  no Encontrada");
        }else{
            this.Mostrar(u);
        }
      }
        

    }//GEN-LAST:event_jBBuscarActionPerformed

    private void jBRegistrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBRegistrarActionPerformed
        //Registrar
        if(jBRegistrar.getText().equals("GUARDAR")){

            Usuario u = new Usuario();
            u.setNombre(jTNombre.getText());
            u.setNombre_usuario(jTxtNombreUsuario.getText());
            u.setContraseña(jPasswordField1.getText());
            u.setTipo(jComboBox.getSelectedItem().toString());
            Au.Registrar(u);
            this.Actualizar();

        }else{
            this.ActivarCampo();
            this.jBRegistrar.setText("GUARDAR");
            this.jBBuscar.setText("CANCELAR");
            ImageIcon[] img_Btns = new ImageIcon[8];
            img_Btns[0] = new ImageIcon(getClass().getResource("/Imagenes/"
                    + "stop_alt.png"));
            jBBuscar.setIcon(img_Btns[0]);
            this.LimpiarCampos();
            
        }

    }//GEN-LAST:event_jBRegistrarActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // Eliminar
            if(condicion==true){
                int question = JOptionPane.showConfirmDialog(null,"¿Seguro que desea"
                        + " eliminar este Cuenta?","Informacion",JOptionPane.YES_NO_OPTION);
                if(question==0){
                    int posicion=this.jTable1.getSelectedRow();
                    u = Au.getUsuarios().get(posicion);
                    dtm.removeRow(posicion);
                    Au.Eliminar(u.getNombre_usuario());
                }else{
                    JOptionPane.showMessageDialog(null, "Peticion ca"
                            + "ncelada","Informacion",JOptionPane.INFORMATION_MESSAGE);
                }

        }else{
             String ced = JOptionPane.showInputDialog("Digite ID de la cuenta");

                    if(ced!=null){
                        u = Au.Consultar(ced);
                        if(u.getNombre().equals("")){
                            JOptionPane.showMessageDialog(null, "Esta cuenta "
                                    + "no existe");
                        } else {
                            
                            int posi = Au.Posicion(u.getNombre_usuario());
                            dtm.removeRow(posi);
                            Au.Eliminar(u.getNombre_usuario());

                        }


                 }
        }

 this.condicion = false;

    }//GEN-LAST:event_jButton3ActionPerformed

    private void jTable1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTable1KeyTyped

    }//GEN-LAST:event_jTable1KeyTyped

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        // Mostrar
        this.Mostrar(Au.getUsuarios().get(jTable1.getSelectedRow()));

    }//GEN-LAST:event_jTable1MouseClicked

    private void jBModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBModificarActionPerformed
     //Modificar Cuenta
        if(jBModificar.getText().equals("MODIFICAR")){
                if(condicion==true){
                    this.ActivarCampo();
                    u=Au.getUsuarios().get(jTable1.getSelectedRow());;
                    Mostrar(u);
                    jBModificar.setText("GUARDAR");
                    ImageIcon[] img_Btns = new ImageIcon[8];
                    img_Btns[0] = new ImageIcon(getClass().getResource(""
                            + "/Imagenes/Floppy.png"));
                    jBModificar.setIcon(img_Btns[0]);

                    jBBuscar.setText("CANCELAR");
                    this.CambiarIconoBuscar();
                    JOptionPane.showMessageDialog(null, "Se han activado "
                            + "los campos para su edicion");
                }else{
                     ced = JOptionPane.showInputDialog("Digite ID de la Cuenta");

                    if(ced!=null){
                        u = Au.Consultar(ced);

                        if(u.getNombre().equals("")){
                            JOptionPane.showMessageDialog(null, "Este Cuenta "
                                    + "no existe");
                        } else {
                            this.Mostrar(u);
                            this.ActivarCampo();
                               jBModificar.setText("GUARDAR");
                                ImageIcon[] img_Btns = new ImageIcon[8];
                                img_Btns[0] = new ImageIcon(getClass().
                                        getResource("/Imagenes/Floppy.png"));
                                jBModificar.setIcon(img_Btns[0]);
                                jBBuscar.setText("CANCELAR");
                                JOptionPane.showMessageDialog(null, "Se"
                                 + " han activado los campos para su edicion");
                        }
                     }
                }
                vc.add(u);
        }else{

            Usuario us = new Usuario();
            us.setNombre(jTNombre.getText());
            us.setNombre_usuario(jTxtNombreUsuario.getText());
            us.setContraseña(jPasswordField1.getText());
            us.setTipo(jComboBox.getSelectedItem().toString());

            u=vc.get(0);
            Au.Modificar(u.getNombre_usuario(), us);
            this.Actualizar();

        }

        this.condicion = false;




    }//GEN-LAST:event_jBModificarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Cuentausuario().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBBuscar;
    private javax.swing.JButton jBModificar;
    private javax.swing.JButton jBRegistrar;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton6;
    private javax.swing.JComboBox jComboBox;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel1;
    private Imagenes.JPanelTransparente jPanelTransparente4;
    private Imagenes.JPanelTransparente jPanelTransparente5;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTNombre;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTxtNombreUsuario;
    // End of variables declaration//GEN-END:variables

    public void Actualizar(){
        this.dispose();
        Cuentausuario Cu = new Cuentausuario(Au);
        Cu.setLocationRelativeTo(null);
        Cu.setVisible(true);
    }
    public void ActivarCampo(){
        jTNombre.setEditable(true);
        jTxtNombreUsuario.setEditable(true);
        jPasswordField1.setEditable(true);

    }

    public void DesactivarCampo(){
        jTNombre.setEditable(false);
        jTxtNombreUsuario.setEditable(false);
        jPasswordField1.setEditable(false);
    }

    private void LimpiarCampos() {
        jTNombre.setText("");
        jPasswordField1.setText("");
        jTxtNombreUsuario.setText("");
    }

    private void Mostrar(Usuario get) {
        this.jTNombre.setText(get.getNombre());
        this.jTxtNombreUsuario.setText(get.getNombre_usuario());
        this.jPasswordField1.setText("*****");
        String tipo = get.getTipo();
        if(tipo.equals("Administrador")){
            jComboBox.setSelectedIndex(0);
        }else if(tipo.equals("Consultor")){
            jComboBox.setSelectedIndex(1);
        }else if(tipo.equals("Registrador")){
            jComboBox.setSelectedIndex(2);
        }
    }

    private void CambiarIconoBuscar() {
        ImageIcon[] img_Btns = new ImageIcon[8];
            img_Btns[0] = new ImageIcon(getClass().getResource("/Imagenes/stop_alt.png"));
            jBBuscar.setIcon(img_Btns[0]);
    }

}
